from datetime import datetime

class User:
	def __init__(self, user_id: int, username: str, email: str, password: str, role: str = 'student', created_at: datetime = None, is_active: bool = True):
		self.user_id = user_id
		self.username = username
		self.email = email
		self.password = password
		self.role = role  # 角色: student/teacher/admin
		self.created_at = created_at or datetime.now()
		self.is_active = is_active

	def check_password(self, password: str) -> bool:
		return self.password == password

	def to_dict(self) -> dict:
		return {
			'user_id': self.user_id,
			'username': self.username,
			'email': self.email,
			'role': self.role,
			'created_at': self.created_at.isoformat(),
			'is_active': self.is_active
		}
